package com.service.single.example.listener;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 一休
 * @DateTime: 2024/3/5 16:36
 */
@RestController
@RequestMapping("/listener")
public class MyController {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    @GetMapping
    public void test(){
        JSONObject jsonObject =new JSONObject();
        jsonObject.put("username","zhangsan");
        jsonObject.put("password","password");
        applicationEventPublisher.publishEvent(new MyApplicationEvent(jsonObject,"消息创建"));
    }
}
